#include <iostream>
#include <vector>
using namespace std;

template <typename T>
void read(vector <T> &data) {
    int length;
    cin >> length;
    data.resize(length);
    for (int i = 0; i < length; ++i) {
        cin >> data[i];
    }
    return;
}
template <typename T>
void merge(T first_begin,
    T first_end,
    T second_begin,
    T second_end,
    T result_begin,
    T result_end) {
    T buffer = result_begin;
    auto first = first_begin, second = second_begin;
    while (1) {
        if (first == first_end && second == second_end) {
            break;
        }
        else if (first == first_end) {
            *buffer = *second;
            ++second, ++buffer;
        } else if (second == second_end) {
            *buffer = *first;
            ++first, ++buffer;
        } else if (*first < *second) {
            *buffer = *first;
            ++first, ++buffer;
        } else {
            *buffer = *second;
            ++second, ++buffer;
        }
    }
}

template <typename T>
void print(vector <T> &data) {
    for (int i = 0; i < data.size(); ++i) {
        cout << data[i] << ' ';
    }
    return;
}

int main() {
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(0);
    vector <int> a, b;
    read(a);
    read(b);
    vector <int> result(a.size() + b.size());
    merge(a.begin(), a.end(), b.begin(), b.end(), result.begin(), result.end());
    print(result);
}